var OSS = require('ali-oss')

var isPro = false

// 测试库
var testClient = new OSS.Wrapper({
  region: 'oss-cn-shanghai',
  accessKeyId: '7Xrl34cpSSg8lIIj',
  accessKeySecret: '9hnbeQfe6P4JbWTkb9x85xrxni2iWp',
  bucket: 'test-i'
})

// 线上库
var ProClient = new OSS.Wrapper({
  // region: 'oss-cn-hangzhou',
  accessKeyId: '7Xrl34cpSSg8lIIj',
  accessKeySecret: '9hnbeQfe6P4JbWTkb9x85xrxni2iWp',
  bucket: 'mytijian-img',
  endpoint: 'https://oss-cn-hangzhou.aliyuncs.com'
})

var client = isPro ? ProClient : testClient

// 阿里云oss文件上传下载服务
var OssClient = {

  addOssObject: function (targetPath, file, fileName) {
    return client.multipartUpload(targetPath + (fileName || file.name), file)
  },

  deleteOssObject: function (targetPath) {
    return client.delete(targetPath)
  },
  
  putBuffer: function (targetPath, buffer) {
    return client.put(targetPath, buffer)
  },



  endpoint: isPro ? 'https://mytijian-img.oss-cn-hangzhou.aliyuncs.com' : 'https://test-i.oss-cn-shanghai.aliyuncs.com'
}

exports.OssClient = OssClient
